//=======================================================================================
// d3dApp.h by Frank Luna (C) 2008 All Rights Reserved.
//
// Simple Direct3D demo application class.  
// Make sure you link: d3d10.lib d3dx10d.lib dxerr.lib dxguid.lib.
// Link d3dx10.lib for release mode builds instead of d3dx10d.lib.
//=======================================================================================


#ifndef FRAMEWORK_H
#define FRAMEWORK_H

#include "Game Engine\Header\d3dUtil.h"
#include "Game Engine\Header\BulletUtil.h"
#include "Game Engine\Header\GameTimer.h"
#include "Game Engine\Header\TextureMgr.h"
#include "Source\Header\Effects.h"
#include "Source\Header\InputLayouts.h"
#include <string>


class Framework
{
public:
	Framework(HINSTANCE hInstance);
	virtual ~Framework();

	HINSTANCE GetAppInst();
	HWND      GetMainWnd();

	void ResetOMTargetsAndViewport();

	int Run();

	// Framework methods.  Derived client class overrides these methods to 
	// implement specific application requirements.

	virtual void Init();
	virtual void OnResize();// reset projection/etc
	virtual void UpdateScene(float dt);
	virtual void DrawScene(); 
	virtual LRESULT MsgProc(UINT msg, WPARAM wParam, LPARAM lParam);

protected:
	void InitMainWindow();
	void InitDirect3D();
	void InitPhysics();
	
protected:

	HINSTANCE mAppInst;
	HWND      mMainWnd;
	bool      mAppPaused;
	bool      mMinimized;
	bool      mMaximized;
	bool      mResizing;

	GameTimer mTimer;

	std::wstring mFrameStats;
 
	ID3D10Device*    md3dDevice;
	IDXGISwapChain*  mSwapChain;
	ID3D10Texture2D* mDepthStencilBuffer;
	ID3D10RenderTargetView* mRenderTargetView;
	ID3D10DepthStencilView* mDepthStencilView;
	ID3DX10Font* mFont;

	ID3D10EffectTechnique* mBuildShadowMapTech;
	ID3D10EffectMatrixVariable* mfxBuildShadowMapLightWVPVar;
	ID3D10EffectShaderResourceVariable* mfxBuildShadowMapDiffuseMapVar;
	ID3D10EffectMatrixVariable* mfxTexMtxVar;

	// Derived class should set these in derived constructor to customize starting values.
	std::wstring mMainWndCaption;
	D3D10_DRIVER_TYPE md3dDriverType;
	D3DXCOLOR mClearColor;
	int mClientWidth;
	int mClientHeight;

	// Bullet initialization stuff
	// This is the most important bullet class
	btDynamicsWorld*		mDynamicsWorld;

	btBroadphaseInterface *mBP;

	// Keep the collision shapes, for deletion/cleanup
	btAlignedObjectArray<btCollisionShape*>	mCollisionShapes;

	btBroadphaseInterface*	mBroadphase;

	btCollisionDispatcher*	mDispatcher;

	btConstraintSolver*		mSolver;

	btDefaultCollisionConfiguration* mCollisionConfiguration;

	enum
	{
		USE_CCD=1,
		USE_NO_CCD
	};
	int 	mCCDMode;
};




#endif // FRAMEWORK_H